package com.hnyc.shop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hnyc.shop.domain.ShopShopee;
import com.hnyc.shop.service.IShopShopeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * shopController
 * 
 * @author zero
 * @date 2023-03-11
 */
@RestController
@RequestMapping("/shop/shopee")
public class ShopShopeeController extends BaseController
{
    @Autowired
    private IShopShopeeService shopShopeeService;

    /**
     * 查询shop列表
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopShopee shopShopee)
    {
        startPage();
        List<ShopShopee> list = shopShopeeService.selectShopShopeeList(shopShopee);
        return getDataTable(list);
    }

    /**
     * 导出shop列表
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:export')")
    @Log(title = "shop", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopShopee shopShopee)
    {
        List<ShopShopee> list = shopShopeeService.selectShopShopeeList(shopShopee);
        ExcelUtil<ShopShopee> util = new ExcelUtil<ShopShopee>(ShopShopee.class);
        util.exportExcel(response, list, "shop数据");
    }

    /**
     * 获取shop详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopShopeeService.selectShopShopeeById(id));
    }

    /**
     * 新增shop
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:add')")
    @Log(title = "shop", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopShopee shopShopee)
    {
        return toAjax(shopShopeeService.insertShopShopee(shopShopee));
    }

    /**
     * 修改shop
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:edit')")
    @Log(title = "shop", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopShopee shopShopee)
    {
        return toAjax(shopShopeeService.updateShopShopee(shopShopee));
    }

    /**
     * 删除shop
     */
    @PreAuthorize("@ss.hasPermi('shop:shopee:remove')")
    @Log(title = "shop", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopShopeeService.deleteShopShopeeByIds(ids));
    }
}
